"""Box URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from apps.system import views
from django.conf import settings
from django.views import static

from system.views_user import LoginView, RegisterView, LogoutView, ProfileView, ResetView, SendEmailView, \
    ChangePasswordView, ReLoginView, ImageCodeView, EmailUpdateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', RegisterView.as_view(), name='register'),
    path('', LoginView.as_view(), name='index'),    # 首页
    path('login/', LoginView.as_view(), name='login'),
    path('re_login/', ReLoginView.as_view(), name='re_login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('reset/', ResetView.as_view(), name='reset'),
    path('reset/email/', SendEmailView.as_view(), name='email'),
    path('reset/change/', ChangePasswordView.as_view(), name='reset-change'),
    path('email/update/', EmailUpdateView.as_view(), name='email-update'),   # 修改邮箱
    path('profile/', ProfileView.as_view(), name='profile'),
    path('image_code/', ImageCodeView.as_view(), name='image-code'),  # 图片验证码

    path('system/', include('system.urls'), name='system'),
    path('rbac/backend/', include('backend.urls'), name='backend'),
    path('rbac/', include('rbac.urls'), name='rbac'),

]

# DEBUG 为 False 时使用
if not settings.DEBUG:
    urlpatterns += [re_path(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT})]

handler404 = views.page_not_found
